<template>
	<view class="container">
		<uni-list v-for="item, index in classmateList" :key="index">
			<uni-list-chat :avatar-circle="true" :avatar="item.headicon" :title="item.name" :note="item.department"
				:show-badge="true" :badge-text="item.unread" badgeType="error" @click="toDetails(item.id,item.headicon)"
				link>
			</uni-list-chat>
		</uni-list>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				classmateList: [],
				extra: [{
						headicon: "/static/我的.png",
						unread: 6
					},
					{
						headicon: "/static/我的2.png",
						unread: 7
					}
				]
			}
		},
		methods: {
			toDetails(id, headicon) {
				uni.navigateTo({
					url: '/pages/cmdetails/cmdetails?id=' + id
				});
			}
		},
		onLoad() {
			uni.request({
				url: 'http://localhost:8090/freshmenapp/user/list',
				method: 'POST',
				success: res => {
					if (res.data.success) {
						this.classmateList = res.data.list.map((item, index) => {
							return {
								...item,
								...this.extra[index]
							};
						});
					}
				},
				fail: () => {},
				complete: () => {}
			});
		}
	}
</script>

<style>

</style>